package com.sushang.validation;

import com.sushang.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @author chengzhouli
 * @return 如果返回false, 则校验不通过, 如果返回true, 则校验通过
 */
public class StateValidation implements ConstraintValidator<State, String> {


    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        //提供校验规则
        if (value == null) {
            return false;
        }
        if (value.equals("已发布") || value.equals("草稿")) {
            return true;
        }
        return false;
    }
}
